package com.inpion.model.board;

import java.util.HashMap;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;

public abstract class AbstractBrokerModel extends HashMap<String, Object>  implements IBrokerModel{

	private static final long serialVersionUID = 4838920264442826307L;
	private static final String ID = "id";
	private static final String CLASS_NAME = "className";

	@Override
	public JSONObject getJsonModel() {
		JsonConfig config = new JsonConfig();
		config.setExcludes(new String[]{"jsonModel"});
		config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
		return JSONObject.fromObject(this, config);
	}

	public AbstractBrokerModel(String objId) {
		this.put(ID, objId);
		this.put(CLASS_NAME, this.getClass().getName().replaceAll("com.inpion.model.board.", ""));
	}


}
